package io.lkt.modules.sys.service.impl;

import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;

import io.lkt.modules.sys.dao.BArticleStandDao;
import io.lkt.modules.sys.entity.BArticleStandEntity;
import io.lkt.modules.sys.service.BArticleStandService;


@Service("bArticleStandService")
public class BArticleStandServiceImpl extends ServiceImpl<BArticleStandDao, BArticleStandEntity> implements BArticleStandService {

    @Override
    @DataSource("master")
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BArticleStandEntity> page = this.page(
                new Query<BArticleStandEntity>().getPage(params),
                new QueryWrapper<BArticleStandEntity>().orderByDesc("id")
        );

        return new PageUtils(page);
    }

    @DataSource("master")
    public BArticleStandEntity getById(Serializable id) {
        return (BArticleStandEntity)((BArticleStandDao)this.baseMapper).selectById(id);
    }

    @DataSource("master")
    public boolean save(BArticleStandEntity entity)
    {
        return retBool(Integer.valueOf(((BArticleStandDao)this.baseMapper).insert(entity)));
    }

    @DataSource("master")
    public boolean updateById(BArticleStandEntity entity)
    {
        return retBool(Integer.valueOf(((BArticleStandDao)this.baseMapper).updateById(entity)));
    }

    @Override
    @DataSource("master")
    public boolean removeByIds(Collection<? extends Serializable> idList) {
        return SqlHelper.delBool(this.baseMapper.deleteBatchIds(idList));
    }

}
